package view.servlet.knowledge;

import com.alibaba.fastjson.JSON;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pojo.User;
import service.KnowledgeService;
import service.impl.KnowledgeServiceImpl;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author wq3stone
 */

@WebServlet("/queryAll")
public class QueryAll extends HttpServlet {
    KnowledgeService knowledgeService = new KnowledgeServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        req.setCharacterEncoding("UTF-8");
        PrintWriter out = resp.getWriter();
        User user = (User) req.getSession().getAttribute("user");
        out.print(JSON.toJSONString(knowledgeService.queryKlg("uid",String.valueOf(user.getId()))));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
